/*
 * process.h
 * 
 *
 */
 
#ifndef PROCESS_H
#define PROCESS_H

typedef struct p_str {
	int	pid;			// process ID.
	int priority; 		// priority assigned to the process.
	int process_type;   // code for process type, e.g. 0=compute, 1=i0, 2=keyboard, etc.
	int	num_steps;		// number of time steps before resetting to 0 - number of instructions
	int num_requests;	// number of requests that will be generated during the process run
	int req_freq;		// the frequency at which requests are generated.
	int * requests;		// an array of requests, each request (e.g. io service) is issued at a specific
						// time step. These are the synchronous events that result in traps being issued.
						// You can get fancy and make this an array of RequestTypeStr which contains the
						// step number when issued, and a request type (e.g. 0=io, 1=sync, etc.)
	struct p_str* next;        // pointer to the next process
	// pcb info
	int start;
	int next_step;		// this is the step count that the CPU had gotten to when this process was
						// prempted (like a PC register value)
	int state;			// e.g. 0=running, 1=ready, 2=interrupted, 3=blocked
	int waiting_on;		// which queue is it in if it is waiting on something (blocked)
	int owns;			// which mutex lock does it own
	
	// member functions
	int (*updateProc)(struct p_str*); // update the process
	int (*destruct)(struct p_str*);    // destruct
	char* (*toString)(struct p_str*, int*);  // tostring
	} Process;

typedef Process* ProcessPtr;

ProcessPtr ProcessConstruct(int pid, int priority, int type, int steps, int requests, ProcessPtr next);
#endif
